#ifndef UTILS_H
#define UTILS_H

#include<omp.h>
#include<unistd.h>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<sys/time.h>

#define rep(i,x,y) for(int i=x;i<y;++i)

#define BLOCK_SIZE_CUDA 4

typedef double** matrix;

void allocate_matrix(const int n, matrix &a);
void allocate_matrix(const int n, double* &a);
void generate_matrix(const int n, matrix &a);

void destroy_matrix(const int n, matrix a);
void destroy_matrix(double* a);

void output(const int n, matrix a, char* filename);
void output(const int n, double* a, char* filename);
void input(const int n, matrix a, char* filename);
void input(const int n, double* a, char* filename);
void memset_zero(const int n, matrix a);


#define test_time(behavior) {\
    timeval start, end;\
    gettimeofday(&start, NULL);\
    behavior;\
    gettimeofday(&end, NULL);\
    printf("%.5lfsec consumed\n",end.tv_sec-start.tv_sec+(end.tv_usec-start.tv_usec)*1e-6);\
}

#endif // UTILS_H

